﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;
using System.Net;
using System.Xml.Serialization;

namespace ClientApplication
{
    [Serializable]
    public class Judge
    {
        public bool sendScore;

        public string username { get;  set; } //Unik person-ID för att verifiera sig för admin.
        [XmlIgnore]
        public IPEndPoint ipEp { get;  set; }

        public string password { get; set; }

        public override bool Equals(System.Object obj)
        {
            // If parameter is null return false.
            if (obj == null)
            {
                return false;
            }

            // If parameter cannot be cast to Point return false.
            Judge p = obj as Judge;
            if ((System.Object)p == null)
            {
                return false;
            }

            // Return true if the fields match:
            return (this.username == p.username) && (this.ipEp == p.ipEp);
        }

        public void assign(Judge toAssign)
        {
            username = toAssign.username;
            ipEp = toAssign.ipEp;
            password = toAssign.password;

        }

        public Judge()
        {
            sendScore = false;
            ipEp = null;
            username = "";
            password = "";
        }
        public Judge(Judge toCopy)
        {
            this.sendScore = toCopy.sendScore;
            this.username = toCopy.username;
            this.password = toCopy.password;
            this.ipEp = new IPEndPoint(toCopy.ipEp.Address, toCopy.ipEp.Port);
        }

        public Judge(string username , IPEndPoint ipEp, string password)
        {
            this.sendScore = false;
            this.username = username;
            this.ipEp = ipEp;
            this.password = password;
        }
    }
}
